Skip to content

docs: correct way to get the default module in examples #2425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 26, 2021

Conversation

yaonyan
Copy link
Contributor

@yaonyan yaonyan commented Jan 24, 2021

a walkaround for #2423, add default to all of the api module's require method in example code

@escapedcat
Copy link
Member

This is good to go, right?

@armano2
Copy link
Contributor

armano2 commented Feb 5, 2021

not really, only @commitlint/format has non default export, rest of them have only default one

@yaonyan
Copy link
Contributor Author

yaonyan commented Feb 5, 2021

not really, only @commitlint/format has non default export, rest of them have only default one

Yeah. we should revert this . And format has two way to require:

const {format} = require('@commitlint/format')
// or
const format = require('@commitlint/format').default

@yaonyan
Copy link
Contributor Author

yaonyan commented Feb 5, 2021

@armano2 sorry! I only test format api, I didn't dig into other api module's source code

@armano2
Copy link
Contributor

armano2 commented Feb 5, 2021

bdw, format is actually wierd, no clue why this is exported in this way

export {default} from './format';
export * from './format';

thats most likely reason why we have issues with this, package

@yaonyan
Copy link
Contributor Author

yaonyan commented Feb 5, 2021

@escapedcat Anyway, after revert. we are ready to go.

using .default syntax cloud not be wrong

@yaonyan
Copy link
Contributor Author

yaonyan commented Feb 5, 2021

bdw, format is actually wierd, no clue why this is exported in this way

export {default} from './format';
export * from './format';

thats most likely reason why we have issues with this, package

Looks like test file counts on index.ts, that's why we need index.ts. If we change it to ./format(and change the corresponding package.json file), index.ts cloud be removed.

import {format, formatResult} from '.';

Am I right? @escapedcat @armano2

fix(syntax): CommonJS can't require default entry using this
syntax sugar, so revert it
This reverts commit 511c639.
@escapedcat
Copy link
Member

@AdeAttwood maybe we can just merged this?

@AdeAttwood
Copy link
Member

@escapedcat yea I think merge this in, so the docs are correct.

I do like the destructuring syntax but could not get that to work. I think looking into that will be cool.

@escapedcat escapedcat merged commit b12abb8 into conventional-changelog:master Apr 26, 2021
@escapedcat
Copy link
Member

Thanks people!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants